﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Collections;


namespace Skyttespill
{
    public partial class HighForm : Form
    {
        ArrayList list = new ArrayList();
        public HighForm()
        {
            InitializeComponent();
            Les(@"High.txt");
        }

        public void Les(string path)
        {
            StreamReader read = new StreamReader(path);

            string lines = string.Empty;

            while ((lines = read.ReadLine()) != null)
            {
                list.Add(lines);
            }

            foreach(string line in list)
            {
                ScoreBox.Text += line + "\n";
            }
        }

        private void textBox2_TextChanged(object sender, EventArgs e)
        {

        }

        private void HighForm_Load(object sender, EventArgs e)
        {

        }

        private void CloseButton_Click(object sender, EventArgs e)
        {
            Close();
        }

        private void SlettButton_Click(object sender, EventArgs e)
        {
            var slett = MessageBox.Show("Vil du slette listen?", "ja", MessageBoxButtons.OKCancel);

            if (slett == DialogResult.OK)
            {
                using (FileStream stream = new FileStream(@"High.txt", FileMode.Create))
                using (TextWriter writer = new StreamWriter(stream))
                { 
                
                }
                ScoreBox.Clear();
            }
        }
    }
}
